using System.Windows;
using Shatkotha.WPF.Global.Common.Controls.Dialog;
using Shatkotha.WPF.Global.Data;
using Shatkotha.WPF.Global.Modules.Contacts;

namespace Shatkotha.WPF.Contacts.Presenters
{
    public class ContactEditorPresenter:ADialogContentPresenter,IContactEditorPresenter
    {
        public DependencyProperty PersonProperty = DependencyProperty.Register("PersonProperty", typeof(IPerson), typeof(ContactEditorPresenter));

        public Person Person
        {
            get
            {
                return GetValue(PersonProperty) as Person;
            }
            set
            {
               SetValue(PersonProperty,value); 
            }
        }

        public ContactEditorPresenter(IContactEditorView view) : base(view)
        {
        }
        public override bool OnClosing(DialogResult dialogResult)
        {
            if(dialogResult == DialogResult.Cancel)
                return base.OnClosing(dialogResult);
            if (dialogResult == DialogResult.OK && ((IContactEditorView)View).IsValid())
            {
                return base.OnClosing(dialogResult);
            }
            return false;
        }
    }
}